﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Timers;

using static System.Console;



namespace 事件
{
    internal class Program
    {
        static int counter = 0;
        static string displayString = "this string will appear one letter at a time.";
        static void Main(string[] args)
        {
            Timer myTimer = new Timer(100);
            //myTimer.Elapsed += new ElapsedEventHandler(WriteChar);
            myTimer.Elapsed += WriteChar;
            myTimer.Start();
            System.Threading.Thread.Sleep(1000);
            ReadKey();

        }

        static void WriteChar(object source,ElapsedEventArgs e)
        {
            Write(displayString[counter++ % displayString.Length]);
        }
    }
}
